//
// Created by huili on 2022/3/6.
//
#include <stdio.h>
#include <stdlib.h>


#define SIZE1 4
#define SIZE2 6

void merge(int *nums1, int nums1Size, int m, int *nums2, int nums2Size, int n);
void MergeTwoArrays() {
    int num1[SIZE1] = {1, 3, 6, 7};
    int num2[SIZE2] = {1,2,4,5,8,10};

        merge(num1,0,4,num2,0,6);



}

void merge(int *nums1, int nums1Size, int m, int *nums2, int nums2Size, int n) {
    int cur;
    int p1, p2;
    int nums[m + n - 1];
    while (p1 < m || p2 < n) {
        if(p1 == m){
            cur = nums2[p2++];
        }else if(p2 == n){
            cur = nums1[p1++];
        }else if(nums1[p1] < nums2[p2]){
            cur = nums1[p1++];
        } else{
            cur = nums2[p2++];
        }
        nums[p1+p2-1] = cur;
    }
    int i;
    for (i = 0; i != m + n; ++i) {
        nums1[i] = nums[i];
    }
}

